<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="s_norm" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="popAddNorm('')" type='success' size="mini"><i class='fa fa-plus'></i>增加规格</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 规格列表 </span>
          </div>
          <el-table :data="s_norm">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_norm('&CMIDnorm_id='+scope.row.norm_id+'')">删除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popModiffyNorm('&CMIDnorm_id='+scope.row.norm_id+'')">修改</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage('/mes/certificate/KeyComponentNorm?CMIDnorm_id='+scope.row.norm_id+''+vueparams+'')">关联关键件</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="#" align="center" type='index'>
            </el-table-column>
            <el-table-column label="规格" prop="norm" width="300">
              <template slot-scope="scope">
                <el-link @click="gotoPage('/mes/certificate/AddKeyComponentNorm?CMIDnorm_id='+scope.row.norm_id+'&cpopup=reload'+vueparams+'')" type='primary'>&nbsp;&nbsp;&nbsp;关联关键件</el-link>
              </template>
            </el-table-column>
            <el-table-column label="型号" prop="cer_model_name" width="200">
            </el-table-column>
            <el-table-column label="关键件" prop="cer_part_name" width="200">
            </el-table-column>
            <el-table-column label="产品名称" prop="product_name">
            </el-table-column>
            <el-table-column label="增加时间" prop="entered">
              <template slot-scope="scope">
                {{getDateTimeString(scope.row,'entered')}}
              </template>
            </el-table-column>
          </el-table>
          <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'适用规格'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="AddNormVisible" append-to-body>
      <AddNorm v-if="AddNormVisible" ref="AddNorm" :popparams="popparams"> </AddNorm>
    </el-dialog>
    <el-dialog :visible.sync="ModiffyNormVisible" append-to-body>
      <ModiffyNorm v-if="ModiffyNormVisible" ref="ModiffyNorm" :popparams="popparams"> </ModiffyNorm>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import AddNorm from "@/views/mes/certificate/AddNorm";
  import ModiffyNorm from "@/views/mes/certificate/ModiffyNorm";
  export default {
    name: 'ApplicableNorm',
    components: {
      AddNorm,
      ModiffyNorm,
    },
    props: ['popparams'],
    data() {
      return {
        AddNormVisible: false,
        AddNormValue: null,
        AddNormDesc: null,
        ModiffyNormVisible: false,
        ModiffyNormValue: null,
        ModiffyNormDesc: null,
        vueparams: this.getVUEParams(""),
        s_norm: [],
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "018E412E935E4B3EB6DF631BB3B46A50",
        name: "客户右菜单类型",
        selected: "适用规格"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/certificate/CertificateAction/applicableNorm?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_norm(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/certificate/CertificateAction/d_norm?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popAddNorm(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.AddNormVisible = !this.AddNormVisible;
      },
      popModiffyNorm(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ModiffyNormVisible = !this.ModiffyNormVisible;
      },
    },
  }
</script>
